home *** CD-ROM | disk | FTP | other *** search
/ Netscape Plug-Ins Developer's Kit / Netscape_Plug-Ins_Developers_Kit.iso / CGIPERL / MACPERL / MSRCE418.HQX / Perl Source ƒ / Perl / MkInit < prev    next >
Encoding:
Text File  |  1994-08-01  |  1.5 KB  |  82 lines

  1. Perl -Sx "{0}" {"Parameters"}; Exit 0
  2. #!perl
  3.  
  4. @PP = (0);
  5.  
  6. $PP{"DEBUGGING"} = 1;
  7. $PP{"macintosh"} = 0;
  8. $PP{"MSMAC"} = 0;
  9. $PP{"STDMAC"} = 0;
  10. $suppress = 0;
  11.  
  12. while (<>) {
  13.     if (/^#if(n?)def\s+(\w+)/) {
  14.        if ($suppress) {
  15.             unshift(@PP, 1);
  16.             next;
  17.         }
  18.         if ($1 ne "n") {
  19.             if (!defined($PP{$2})) {
  20.                 $suppress = 1;
  21.                 unshift(@PP, 1);
  22.             } elsif ($PP{$2}) {
  23.                 print;
  24.                 unshift(@PP, -1);
  25.             } else {
  26.                 unshift(@PP, 0);
  27.             }
  28.         } else {
  29.             if (defined($PP{$2}) && !$PP{$2}) {
  30.                 $suppress = 1;
  31.                 unshift(@PP, 1);
  32.             } elsif ($PP{$2}) {
  33.                 print;
  34.                 unshift(@PP, -1);
  35.             } else {
  36.                 unshift(@PP, 0);
  37.             }
  38.         }
  39.     } elsif (/^#if/) {
  40.         $suppress = 1;
  41.         unshift(@PP, 1);
  42.     } elsif (/^#else/) {
  43.         next if $suppress;
  44.         if (!$PP[0]) {
  45.             $suppress = 1;
  46.             $PP[0] = 1;
  47.         } elsif ($PP[0]==1) {
  48.             $suppress = 0;
  49.             $PP[0] = 0;
  50.         } else {
  51.             print;
  52.         }
  53.     } elsif (/^#endif/) {
  54.         print if ($PP[0]==-1);
  55.         shift @PP;
  56.        $suppress = ($PP[0] == 1);
  57.     }
  58.     next if ($suppress);
  59.     s/MP_//g;
  60.     if (/^EXT\s+(.*\W)(\w+);/) {
  61.         ($type,$var) = ($1,$2);
  62.         if ($type =~ /\*\s*$/) {
  63.             print "\t$var = NULL;\n";
  64.         } else {
  65.             $type =~ /^(.*\S)\s*$/;
  66.             print "\tmemset(&$var, 0, sizeof($1));\n";
  67.         }
  68.     } elsif (/^EXT\s+(.*\W)(\w+)\s*\[([^\]]+)\];/) {
  69.         ($type,$var,$idx) = ($1,$2,$3);
  70.         $type =~ /^(.*\S)\s*$/;
  71.         print "\tmemset(&$var, 0, sizeof($1)*$idx);\n";
  72.     } elsif (/^EXT.*\{/) {
  73.         while (<>) {
  74.             last if (/\}/);
  75.         }
  76.         ($var) = ($_ =~ /(\w+)/);
  77.         print "\t$var = NULL;\n";
  78.     } elsif (/^EXT.*\W(\w+)\s+INIT\((.+)\)\s*;/) {
  79.         print "\t$1 = $2;\n";
  80.     }
  81. }
  82.